package com.xinqi.modules.chat.job;

import com.xinqi.common.base.utils.uuids.UUIDs;
import com.xinqi.modules.chat.chat.friend.service.ChatFriendApplyService;
import com.xinqi.modules.chat.chat.message.service.ChatRemindMessageService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class ChatXxlJob {

    private final ChatFriendApplyService chatFriendApplyService;

    private final ChatRemindMessageService chatRemindMessageService;

    /**
     * 好友申请-过期处理
     *
     * @throws Exception
     */
    @XxlJob("applyFriendTime")
    public ReturnT<String> applyFriendTime() throws Exception {
        String uid = UUIDs.uuidStr();
        log.debug("job executor! {}, 好友申请过期处理任务-开始", uid);
        chatFriendApplyService.applyFriendTimeService();
        log.debug("job executor! {}, 好友申请过期处理任务-结束", uid);
        return ReturnT.SUCCESS;
    }

    /**
     * 消息提醒-定时提醒
     *
     * @throws Exception
     */
    @XxlJob("sendRemindMessage")
    public ReturnT<String> sendRemindMessage() throws Exception {
        String uid = UUIDs.uuidStr();
        log.debug("job executor! {}, 消息提醒定时提醒任务-开始", uid);
        chatRemindMessageService.sendRemindMessage();
        log.debug("job executor! {}, 消息提醒定时提醒任务-结束", uid);
        return ReturnT.SUCCESS;
    }

}
